package com.sgb.knowledgeshare.view.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.knowledgeshare.BR;
import com.sgb.knowledgeshare.R;
import com.swgk.core.base.model.entity.VideoBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class ShareUserListAdapter extends BaseRecycleAdapter<VideoBean> {


    public ShareUserListAdapter(Context context, List<VideoBean> datas) {
        super(context, R.layout.item_share_user_list, datas);
    }

    @Override
    public void onBindViewHolder(ItemViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
       /* RelativeLayout rlitem = holder.itemView.findViewById(R.id.rl_item);
        int pos = position;
        rlitem.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PlayListActivity.initPos = pos;
                context.startActivity(new Intent(context, PlayListActivity.class));
            }
        });*/
    }

    @Override
    public void convert(ItemViewHolder holder, final VideoBean entity) {
        holder.setBinding(BR.viewModel, entity);
        ImageView itemimvs = holder.itemView.findViewById(R.id.item_imv);
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.share_classify_loading)//图片加载出来前，显示的图片
                .fallback( R.mipmap.share_classify_failure) //url为空的时候,显示的图片
                .error(R.mipmap.share_classify_failure);//图片加载失败后，显示的图片
       Glide.with(context).load(entity.getCover()).apply(options).into(itemimvs);
    }
}
